# -*- coding: utf-8 -*-

#ParallelPlatform Project - A web platform to distribute and share knowledge
#Copyright (C) 2011  Daniel Guerrero Martinez & Sergio Rodriguez Lumley
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.
#
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>.


# Django settings for ParallelPlatform project.
import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': os.path.normpath( os.path.join( os.path.dirname(__file__), 'data.db' ) ),
        #'NAME': 'D:\\Universidad\\Proyecto\\Eclipse\\ParallelPlatform\\data.db',                      # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

#DATABASES = {
#    'default': {
#        'ENGINE': 'mysql', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
#        'NAME': 'parallelplatform',
#        'USER': 'parallelplatform',                      # Not used with sqlite3.
#        'PASSWORD': 'parallelplatform',                  # Not used with sqlite3.
#        'HOST': 'db4free.net',                      # Set to empty string for localhost. Not used with sqlite3.
#        'PORT': '3306',                      # Set to empty string for default. Not used with sqlite3.
#    }
#}



EMAIL_HOST = "smtp.gmail.com"
EMAIL_PORT = 587
EMAIL_HOST_USER = "parallelplatformproject@gmail.com"
EMAIL_HOST_PASSWORD = "danisergio"
EMAIL_USE_TLS = True
EMAIL_SUPPORT = "parallelplatformproject@gmail.com"

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Madrid'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
#LANGUAGE_CODE = 'en'

ugettext = lambda s: s # dummy ugettext function, as django's docs say

LANGUAGES = (
    ('en', ugettext("English")),
    ('es', ugettext("Español")),
)

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True

# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.normpath( os.path.join( os.path.dirname(__file__), 'media/' ) ) 


# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/media/admin/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'f9r6ct@lflp$_=kqqji(kty@p(u(bf17+34&z4z6_gnp^8a0n2'

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.Loader',
    'django.template.loaders.app_directories.Loader',
#     'django.template.loaders.eggs.Loader',
)

PROJECT_DIR = os.path.dirname(__file__)

TEMPLATE_DIRS = (
    os.path.join(PROJECT_DIR, "templates"),
    # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
    # Always use forward slashes, even on Windows.
    # Don't forget to use absolute paths, not relative paths.
)

TEMPLATE_CONTEXT_PROCESSORS= (
    'django.core.context_processors.request',
    'django.core.context_processors.csrf',
    'django.contrib.auth.context_processors.auth',
#    'django.core.context_processors.PermWrapper',
    'django.core.context_processors.debug',
    'django.core.context_processors.i18n',
    'django.contrib.messages.context_processors.messages',
    'ParallelPlatform.middleware.theme.contextTheme',
    'ParallelPlatform.middleware.theme.contextMenuLink',
#    default:
#    ("django.contrib.auth.context_processors.auth",
#     "django.core.context_processors.debug",
#     "django.core.context_processors.i18n",
#     "django.core.context_processors.media",
#     "django.core.context_processors.static",
#     "django.contrib.messages.context_processors.messages")
)

MIDDLEWARE_CLASSES = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.middleware.locale.LocaleMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'ParallelPlatform.middleware.theme.theme',
)


ROOT_URLCONF = 'ParallelPlatform.urls'

LOGIN_REDIRECT_URL="/"

MESSAGE_STORAGE = 'django.contrib.messages.storage.fallback.FallbackStorage'

#This is the number of days users will have to activate their
#    accounts after registering. If a user does not activate within
#    that period, the account will remain permanently inactive and may
#    be deleted by maintenance scripts provided in django-registration.
ACCOUNT_ACTIVATION_DAYS = 2

AUTHENTICATION_BACKENDS = (
    'ParallelPlatform.userManager.regbackend.EmailBackend',
)

AUTH_PROFILE_MODULE = 'userManager.Profile'

INSTALLED_APPS = (
    'django.contrib.sessions',
    'django.contrib.contenttypes',
    'django.contrib.messages',
    'django.contrib.auth',
    'wiki',
    'resources',
    'userManager',
    'registration',
    #'django.contrib.sites',
    # Uncomment the next line to enable the admin:
    'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
)

WIKI_TEMPLATE_DIR = os.path.normpath( os.path.join( os.path. dirname(__file__), 'wiki/pageTemplate' ) )

# (id, file_template, (children templates))
# Those lists that have only one element, need to end up in 'coma' (,)
WIKI_TEMPLATE = (
    (0, 'root.xml', (1,3,4,15)),
    (1, 'apis.xml', (2,)),
    (2, 'language.xml', (6,10,11,12)),
    (3, 'software.xml', (13,)),
    (4, 'courses.xml', (14,)),
    (5, 'theory.xml',()),
    (6, 'tutorial.xml',()),
    (7, 'function.xml',()),
    (8, 'practices.xml',(18,)),
    (9, 'teacher.xml',()),
    (10, 'functions.xml',(7,)),
    (11, 'dataTypes.xml',(19,)),
    (12, 'consts.xml',(20,)),
    (13, 'program.xml', (16,17)),
    (14, 'course.xml', (5,8,9)),
    (15, 'help.xml', ()),
    (16, 'howtoinstall.xml', ()),
    (17, 'howtouse.xml', ()),
    (18, 'laboratory.xml', ()),
    (19, 'datatype.xml', ()),
    (20, 'const.xml', ()),
)

RESOURCES_TYPES = {
    'img': ('jpg','jpeg','png','gif'),
    'anim': ('plpanim','swf'),
}

DEFAULT_THEME = 'newstyle'

THEMES = {'newstyle': ugettext("Horizon"),
         'pdpstyle' : ugettext("Focus")}

MENU_LINK = (
             (ugettext('APIs') , '/'),
             (ugettext('Software') , '/'),
             (ugettext('Courses') , '/'),
             (ugettext('Help') , '/'),
            )

# Check wiki/urls.py to see what names cannot be used
SHORTCUT_LINK = (
             ('apis' , '/'),
             ('software' , '/'),
             ('courses' , '/'),
             ('help' , '/'),
            )


